package br.com.unitunes.session;

import br.com.caelum.vraptor.ioc.Component;
import br.com.caelum.vraptor.ioc.SessionScoped;
import br.com.unitunes.model.Perfil;
import br.com.unitunes.model.Usuario;

@Component
@SessionScoped
public class UserSession {

    private Usuario user;

    public boolean isLogged() {
        return user != null;
    }

    public void logout() {
        user = null;
    }

	public Usuario getUser() {
		return user;
	}

	public void setUser(Usuario user) {
		this.user = user;
	}
	
	public boolean userIsAdmin()
	{
		if(this.user == null) return false;
		
		return this.user.getPerfil().equals(Perfil.ADMINISTRADOR);
	}
}